package com.contractpage.ec;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.contractpage.common.persistence.Page;
import com.contractpage.ec.entity.ContractInbound;
import com.contractpage.ec.entity.ExpressInformation;
import com.contractpage.ec.service.ExpressInformationService;
import com.contractpage.util.StringUtils;

@Controller
@RequestMapping(value = "expressInformation")
public class ExpressInformationController extends BaseController{

	@Autowired
	private ExpressInformationService expressInformationService;

	/**
	 * 配送签收
	 * @param entity
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "trackSign")
	@ResponseBody
	public Object trackSign(ExpressInformation entity, HttpServletRequest request, HttpServletResponse response, Model model){
		setUser(entity);
		return  expressInformationService.trackSign(entity);
	}
	/**
	 * 撤销配送签收
	 * @param entity
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "trackSignCancel")
	@ResponseBody
	public Object trackSignCancel(ExpressInformation entity, HttpServletRequest request, HttpServletResponse response, Model model){
		setUser(entity);
		return  expressInformationService.trackSignCancel(entity);
	}
	
	@RequestMapping(value = "findDetails")
	@ResponseBody
	public Object findDetails(ExpressInformation entity, HttpServletRequest request, HttpServletResponse response){
		Page<ExpressInformation> page = new Page<ExpressInformation>(request,response);
		return expressInformationService.findDetails(page,entity);
	}
	
	@RequestMapping(value = "findList")
	@ResponseBody
	public Object findList(ExpressInformation entity, HttpServletRequest request, HttpServletResponse response, Model model){
		Page<ExpressInformation> page = new Page<ExpressInformation>(request,response);
		return  expressInformationService.findList(page, entity);
	}
	@RequestMapping(value = "findListByType")
	@ResponseBody
	public Object findListByType(ExpressInformation entity, HttpServletRequest request, HttpServletResponse response, Model model){
		Page<ExpressInformation> page = new Page<ExpressInformation>(request,response);
		return  expressInformationService.findListByType(page, entity);
	}
	@RequestMapping(value = "save")
	@ResponseBody
	public Object save(ExpressInformation entity, HttpServletRequest request, HttpServletResponse response, Model model){
		setUser(entity);
		int i = StringUtils.isEmpty(entity.getId())?expressInformationService.insert(entity):expressInformationService.update(entity);
		return i;
	}
	@RequestMapping(value = "delete")
	@ResponseBody
	public Object delete(ExpressInformation entity, HttpServletRequest request, HttpServletResponse response, Model model){
		setUser(entity);
		return expressInformationService.delete(entity);
	}
	@RequestMapping(value = "findById")
	@ResponseBody
	public Object findById(ExpressInformation entity, HttpServletRequest request, HttpServletResponse response, Model model){
		return expressInformationService.get(entity);
	}
	
	@RequestMapping(value = "saveReturn")
	@ResponseBody
	public Object saveReturn(ExpressInformation entity, HttpServletRequest request, HttpServletResponse response, Model model){
		setUser(entity);
		return expressInformationService.saveReturn(entity);
	}
	@RequestMapping(value = "returnSign")
	@ResponseBody
	public Object returnReturn(ExpressInformation entity,HttpServletRequest request, HttpServletResponse response){
		setUser(entity);
		return expressInformationService.returnSign(entity);
	}
	@RequestMapping(value = "problemeContractReturn")
	@ResponseBody
	public Object problemeContractReturn(ExpressInformation entity,HttpServletRequest request, HttpServletResponse response){
		setUser(entity);
		return expressInformationService.problemeContractReturn(entity);
	}
	@RequestMapping(value = "getExpressInformation")
	@ResponseBody
	public Object getExpressInformation(ExpressInformation entity,HttpServletRequest request, HttpServletResponse response){
		return expressInformationService.get(entity);
	}
	/**
	 * 认购确认书签收
	 * @param entity
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "confirmationSign")
	@ResponseBody
	public Object confirmationSign(ExpressInformation entity, HttpServletRequest request, HttpServletResponse response, Model model){
		return  expressInformationService.confirmationSign(entity);
	}
	/**
	 * 取消认购确认书签收
	 * @param entity
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "confirmationSignCancel")
	@ResponseBody
	public Object confirmationSignCancel(ExpressInformation entity, HttpServletRequest request, HttpServletResponse response, Model model){
		return  expressInformationService.confirmationSignCancel(entity);
	}
	
	/**
	 *保存调配
	 * @param entity
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "saveChangeEexpressInformation")
	@ResponseBody
	public Object saveChangeEexpressInformation(ExpressInformation entity, HttpServletRequest request, HttpServletResponse response, Model model){
		setUser(entity);
		int i = expressInformationService.saveChangeEexpressInformation(entity);
		return i;
	}
	/**
	 * 撤销调配
	 * @param entity
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "returnExpressInformation")
	@ResponseBody
	public Object returnExpressInformation(ExpressInformation entity, HttpServletRequest request, HttpServletResponse response, Model model){
		setUser(entity);
		int i = expressInformationService.returnExpressInformation(entity);
		return i;
	}
}